-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split codec from scheme #17922
Split codec from scheme #17922
Conversation
GCE e2e build/test failed for commit 0be0992. |
Labelling this PR as size/XXL |
Any chance of breaking the codec method signature changes in a separate pull? |
) | ||
|
||
type serializerType struct { | ||
AcceptContentTypes []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this extend any interfaces? Seems like I'd want this to actually be an interface.
Also, public fields on a private struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not for end users, merely to enable local code to extend it (for
now).
On Mon, Nov 30, 2015 at 7:49 AM, David Eads notifications@github.com
wrote:
In pkg/api/latest/codec.go
#17922 (comment)
:
- "k8s.io/kubernetes/pkg/conversion"
- "k8s.io/kubernetes/pkg/runtime"
- "k8s.io/kubernetes/pkg/runtime/serializer/json"
- "k8s.io/kubernetes/pkg/runtime/serializer/recognizer"
+)
+var (
- Codecs CodecFactory
- UniversalDeserializer runtime.Decoder
- jsonSerializer = json.NewSerializer(conversion.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme))
- yamlSerializer = json.NewYAMLSerializer(conversion.DefaultMetaFactory, api.Scheme, runtime.ObjectTyperToTyper(api.Scheme))
+)
+type serializerType struct {
- AcceptContentTypes []string
Does this extend any interfaces? Seems like I'd want this to actually be
an interface.Also, public fields on a private struct?
—
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/17922/files#r46138851.
It's far too invasive - I want to get a fully working system back before I On Mon, Nov 30, 2015 at 7:48 AM, David Eads notifications@github.com
|
I have a bunch of stuff to catch up on, but I will try to look at this asap |
"k8s.io/kubernetes/pkg/runtime/serializer/recognizer" | ||
) | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently, every time I've written code with global variables like this, I've later regretted it and replaced with some containing object. It makes testing easier, construction more well defined, etc. Up to you though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree as well - I need to break the code that depends on global
codecs today, and identify where codec is an injection vs global. There
are a few places where universal decoder is all that is all that is needed,
but injection is still important.
On Dec 1, 2015, at 7:07 PM, Daniel Smith notifications@github.com wrote:
In pkg/api/latest/codec.go
#17922 (comment):
+package latest
+
+import (
- "fmt"
- "io"
- "reflect"
+- "k8s.io/kubernetes/pkg/api"
- "k8s.io/kubernetes/pkg/api/unversioned"
- "k8s.io/kubernetes/pkg/conversion"
- "k8s.io/kubernetes/pkg/runtime"
- "k8s.io/kubernetes/pkg/runtime/serializer/json"
- "k8s.io/kubernetes/pkg/runtime/serializer/recognizer"
+)
+
+var (
Recently, every time I've written code with global variables like this,
I've later regretted it and replaced with some containing object. It makes
testing easier, construction more well defined, etc. Up to you though.
—
Reply to this email directly or view it on GitHub
https://github.com/kubernetes/kubernetes/pull/17922/files#r46359926.
I'm sure I missed things, hopefully not big things. The nuance of Codec and Serializer was not at all obvious to me, but I can't think of better names off the top of my head. Is Scheme still doing any useful work? I think the stuff in the latest package needs to be reflected in the testapi package, or extracted to some common place (I think that sort of thing was the intended purpose of Scheme?) for use by both. |
Agree something needs to be done with latest and testapi. As I'm walking On Dec 1, 2015, at 7:49 PM, Daniel Smith notifications@github.com wrote: I'm sure I missed things, hopefully not big things. The nuance of Codec and Serializer was not at all obvious to me, but I Is Scheme still doing any useful work? I think the stuff in the latest package needs to be reflected in the — |
GCE e2e test build/test passed for commit 3262d8e. |
LGTM, let's merge-- we can make incremental changes after this is in. |
Adding label |
@k8s-bot test this Tests are more than 48 hours old. Re-running tests. |
GCE e2e test build/test passed for commit 3262d8e. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e test build/test passed for commit 3262d8e. |
Automatic merge from submit-queue |
Auto commit by PR queue bot
@k8s-oncall this is the biggest change that landed this morning, haven't ruled out it might not cause some of the more esoteric (non core e2e) tests to flake. Please ping me immediately if you see squirrelly behavior this morning. |
I don't think this is the cause of https://console.cloud.google.com/storage/browser/kubernetes-jenkins/logs/kubernetes-e2e-gke-ci/10448/ |
gce-autoscaling works locally for me with gcr.io/google_containers/heapster:v0.18.4 and the latest staged source (from https://console.cloud.google.com/storage/browser/kubernetes-jenkins/logs/kubernetes-e2e-gce-autoscaling/2541/?pli=1) |
Move all serialization (codec) responsibilities out of the scheme. Separate serialization
responsibilities of codec from versioning responsibilities of codec.
Enforce that all objects have a version (add __internal and
__unversioned to represent those). Remove runtime.EmbeddedObject in favor
of pure runtime.Object -> runtime.RawExtension.
Disable the automatic encoding of runtime.Object during conversion - instead, require well behaved clients to interpret []runtime.Object themselves. This removes the need for conversion to be aware of codecs (and of objects that the conversion may not have registered).
Dramatically reduce the signature for Codec. On Decode, pass a GVK tuple that
represents the desired decoding. Return from the decode the actual origin type
that the user presented (will allow resthandler to do checking orthogonal to
behavior in codec). Serializer and Codec look the same - the Codec type is
for cases where conversion is in play, the serializer is where only raw wire
format is considered. Decode now returns enough info to make the right
decisions at both levels
Begins addressing #7111 and required to support protobuf #17854 (cannot
assume only one serialization type and 1 codec per version)